<?php include DIR_MODULES . 'menu/menu_main_search.php'; ?>

<table cellpadding="0" cellspacing="0" width="960px" border="0" align="center">
	<tr>
		<td  id="coloana_dreapta_root_corp" valign="top">
		<!-- mijloc si dreapta //////////////////////////////////// -->
			<table cellpadding="0" cellspacing="0" width="100%" border="0">
				<tr>
					<td id="content_corp" valign="top">
					<!-- articole mijloc /////////////////////////////////////// -->
						<div class="mijloc_root">
						<?php 
							$word = mysql_real_escape_string($_POST['search']);
							$word = trim($word);
							$word = strip_tags($word);
						?>
							<div class="titlu_rezultate">Toate rezultatele pentru <b>&quot;<?php echo $word?>&quot;</b></div>
							<div class="mijloc_hr">&nbsp;</div>


<?php
$dataPG = mysql_query("select * from dt_offers where `o_title` like '%$word%' or `o_content` like '%$word%'");
$total_items = mysql_num_rows($dataPG);
$limit = 6;
$page = 1;
								
if((!$limit)  || (is_numeric($limit) == false) || ($limit < 2) || ($limit > 50)) {
	$limit = 3; //default
}
								
$total_pages 	= ceil($total_items / $limit);
if ($total_items>0){
echo '<div id="paginationdemo" class="demo">';
	for($i = 1; $i <= $total_pages; $i++){
		$set_limit 	= $i * $limit - ($limit);
                
		$data = mysql_query("select * from dt_offers where `o_title` like '%$word%' or `o_content` like '%$word%' limit $set_limit,$limit");
		if($i == 1){
			echo '<div id="p'.$i.'" class="pagedemo _current">';
            echo '<div class="mijloc_modul_corporate">';
            echo '<table class="mijloc_modul_corporate" cellpadding="0" cellspacing="0" border="0" width="100%">';
			while ($row = mysql_fetch_array($data)){
				$categories = $dbClass->slc_db_where("dt_categories", "c_id", $row['c_id']);
				$ctgRow = mysql_fetch_array($categories);
											
				$imgs = $offersClass->picViewForOffer($row['o_id']);
				$img = mysql_fetch_array($imgs);
				$photos = mysql_query("select * from dt_offers_photos where o_id = '".$row['o_id']."'");
				$photoRow = mysql_fetch_array($photos);

                                
				echo '<tr>';
                if ($photoRow['oImg_file'] == '')
                	echo '<td valign="top" colspan="2">';
                else
                	echo '<td valign="top">';
                echo '<div class="corporate_pretitlu"><a href="categories/'.$ctgRow['c_id'].'/'.$ctgRow['c_title'].'.html">'.$ctgRow['c_title'].'</a></div>';
                echo '<div class="articol_corp_titlu">'.$row['o_title'].' <b><a href="offers/'.$row['c_id'].'/'.$row['o_id'].'/'.cleanitup($row['o_title']).'.html">'.$row['o_label'].'</a></b></div>';
                echo '<div class="articol_corp_text">';
				echo limitclear($row['o_content'], 300).'...';
				echo '</div>';
				
				if ($row['o_price'] != '')
                	echo '<div class="corporate_postcontent">De la <b>'.$row['o_price'].'</b> '.$row['o_price_type'].'</div>';
				echo '</td>';

				if ($photoRow['oImg_file'] != ''){
                                    echo '<td align="right" valign="bottom" style="padding-bottom:0px;">';
                                    echo '<img class="mijloc_pic" style="margin-left:10px;margin-bottom:10px;" src="uploads/offers/img/'.cleanitup($row['o_title']).'/thumbs/thumb_'.$img['oImg_file'].'" width="160" height="115">';
                                    echo '</td>';
				}
                                echo '<tr><td colspan="2"><div class="mijloc_hr" style="clear:both">&nbsp;</div></td></tr>';
                                echo '</tr>';
			}
                                
				echo '</table>';
                                echo '</div>';
			echo '</div>';
		}
		else {
			echo '<div id="p'.$i.'" class="pagedemo" style="display:none;">';
			while ($row = mysql_fetch_array($data)){
				$categories = $dbClass->slc_db_where("dt_categories", "c_id", $row['c_id']);
				$ctgRow = mysql_fetch_array($categories);
											
				$imgs = $offersClass->picViewForOffer($row['o_id']);
				$img = mysql_fetch_array($imgs);
				$photos = mysql_query("select * from dt_offers_photos where o_id = '".$row['o_id']."'");
				$photoRow = mysql_fetch_array($photos);

                                echo '<div class="mijloc_modul_corporate">';
                                echo '<table class="mijloc_modul_corporate" cellpadding="0" cellspacing="0" border="0" width="100%">';

				echo '<tr>';
                                if ($photoRow['oImg_file'] == '')
                                    echo '<td valign="top" colspan="2">';
                                else
                                    echo '<td valign="top">';
                                echo '<div class="corporate_pretitlu"><a href="categories/'.$ctgRow['c_id'].'/'.$ctgRow['c_title'].'.html">'.$ctgRow['c_title'].'</a></div>';
                                echo '<div class="articol_corp_titlu">'.$row['o_title'].' <b><a href="offers/'.$row['c_id'].'/'.$row['o_id'].'/'.cleanitup($row['o_title']).'.html">'.$row['o_label'].'</a></b></div>';
                                echo '<div class="articol_corp_text">';
				echo limitclear($row['o_content'], 300).'...';
				echo '</div>';
                                echo '<div class="corporate_postcontent">De la <b>'.$row['o_price'].'</b> '.$row['o_price_type'].'</div>';
                                echo '</td>';

				if ($photoRow['oImg_file'] != ''){
                                    echo '<td align="right" valign="bottom" style="padding-bottom:0px;">';
                                    echo '<img class="mijloc_pic" style="margin-left:10px;margin-bottom:10px;" src="uploads/offers/img/'.cleanitup($row['o_title']).'/thumbs/thumb_'.$img['oImg_file'].'" width="160" height="115">';
                                    echo '</td>';
				}
                                echo '<tr><td colspan="2"><div class="mijloc_hr" style="clear:both">&nbsp;</div></td></tr>';
                                echo '</tr>';
			}
                        
			echo '</table>';
                        echo '</div>';
                    echo '</div>';
		}
	}
echo '<div id="demo5"></div></div>';
} else {
	echo '<div class="titlu_rezultate">Nu au fost gasite rezultate.</div>';
}
?>
<script type="text/javascript">
$(function() {
	$("#demo5").paginate({
		count 		: <?php echo $total_pages;?>,
		start 		: 1,
		display     : 6,
		border					: false,
		border_color			: '#fff',
		text_color  			: '#00A5CF',
		background_color    	: 'white',	
		border_hover_color		: '#ccc',
		text_hover_color  		: '#006699',
		background_hover_color	: '#fff', 
		images					: false,
		mouse					: 'press',
		onChange     			: function(page){
                    $('._current','#paginationdemo').removeClass('_current').hide();
                    $('#p'+page).addClass('_current').show();
              }
	});
});
</script>


						</div>
					<!-- end articole mijloc /////////////////////////////////// -->
					</td>
					<td class="coloana_separator" valign="top">&nbsp;</td>
					<?php 
						$cDreapta = mysql_query("select * from dt_mod_visible 
								where z_id = '2'
								and visible = '1'
								and p_id = '8'
								order by `order`");
						//daca nu exista nici un rezultat atunci ascunde coloana
						if (mysql_num_rows($cDreapta)>0){
					?>
					<td id="content_dreapta" valign="top">
			<!-- content dreapta ////////////////////////////////////// -->
                        <?php include DIR_MODULES . 'coloane_module/coloana_dreapta.php'; ?>
			<!-- end content dreapta ////////////////////////////////// -->
					</td>
					<?php }?>
				</tr>
			</table>
		<!-- end mijloc si dreapta //////////////////////////////// -->
		</td>
	</tr>
</table>